#pragma once

#include <uv.h>

#include "uvo.h"

namespace anb { namespace net {

class loop : public uvo {
public:
    loop(const std::string& name = DEFAULT_LOOP_NAME);
    virtual ~loop();

	static const std::string DEFAULT_LOOP_NAME;

	typedef boost::shared_ptr<loop> ptr;

    int start();
    virtual void stop();

    uv_tcp_t* create_tcp();
    static void close(uv_handle_t* handle);
    static void close(uv_tcp_t* tcp);

	void async();

protected:
    static void _closed(uv_handle_t* handle);

private:
    uv_loop_t* m_loop;

};


} }